HAL NOR migration: List of applicable concepts

This section provides information about the HAL NOR applicable architecture concepts.

Concepts for NOR

Concept

Description

Separation of initialization and configuration functions

The initialization has been split into separate initialization and configuration functions:

  • HAL_NOR_Init(): initializes the handle and links it to a NOR instance.

  • HAL_NOR_SetConfig()/ HAL_NOR_SetConfigxxxMemory(): configure the NOR according to the user parameters.

Removal and conversion of init structure to configuration structure

The initialization structure NORSRAM_InitTypeDef is removed and converted into:

  • hal_nor_config_t for common configuration.

  • hal_nor_xxx_memory_config_t for 3 memory configurations depending on the use case.

Renaming of the handle structure

The handle structure NOR_HandleTypeDef has been renamed to hal_nor_handle_t.

Renaming unitary init structures

The initialization structure NORSRAM_InitTypeDef is no longer available and has been replaced by :

  • hal_nor_config_t.

  • hal_nor_xxx_timings_t.

  • hal_nor_memory_config_t.

Remove MspInit and MspDeInit callbacks

The HAL_NOR_MspInit() and HAL_NOR_MspDeInit() are no longer available and have been replaced by a user sequence.

Introduction of HAL user data set/get APIs

Two functions to set and get user data are available: HAL_NOR_SetUserData() and HAL_NOR_GetUserData().

Revised and optimized HAL state machine

The state machine is reworked to ensure transitions of the peripheral functional states.

Revised and optimized HAL API status returns

The HAL NOR functions were updated to return:

  • HAL_INVALID_PARAM: in case of a NULL p_config structure pointer.

  • HAL_TIMEOUT: in case of a user timeout.

  • HAL_OK: in case of a successfully completed operation.

Replaced TypeDef suffix with _t in type names

All TypeDef parts of the HAL NOR driver have been removed and replaced by _t.

Replaced nonmodifiable pointers with const keywords

Const keywords have been added to non-modifiable pointers to ensure that either the pointer itself or the data it points to cannot be modified. This enhances code safety and readability, prevents unintended modifications, and renders code more robust and maintainable.

Assertion implementation and usage in HAL1

The parameters and state are checked using these macros:

  • ASSERT_DBG_STATE.

  • ASSERT_DBG_PARAM.

Rename LL core drivers to stm32_ppp_core.h/.c to avoid confusion with user LL drivers.

The core driver name has been changed from stm32_ll_fmc.h/.c to stm32tnxx_fmc_core.h/.c ( stm32tnxx_fmc_core.h/.c).

Add HAL PPP Services for Drivers with Handle to Retrieve Corresponding Peripheral Clock Frequency.

HAL NOR provides new API to retrieve clock frequency HAL_NOR_GetClockFreq().

Replace Finite Parameter Defines (Including PPP Instances) with Enum Types at HAL Levels.

Finite parameters (including NOR instances) have been converted into enumerated types (enums) at HAL level. This improves code readability, maintainability, and type safety.

Add HAL_PPP Prefix to All HAL Peripheral APIs (Defines, Macros, Types, and Functions).

All HAL NOR functions start with HAL_NOR. All HAL NOR enumerations and structures start with hal_nor.

Other HAL NOR changes

Concept

Consideration

Use directly the sub bank as the unitary instance

Instead of initializing the instance by the base address of the bank 1 then selecting the subbank by configuring the NS bank, the user will choose directly one of the 4 subbanks of bank 1 as instance :

  • HAL_NOR1

  • HAL_NOR2

  • HAL_NOR3

  • HAL_NOR4

Each selection contains the base address of bank 1 plus the subbank offset.

Split the configuration structure into FMC configuration and memory specific configuration

The configuration has been split into:

  • hal_nor_config_t contains the FMC peripheral configuration.

  • hal_nor_xxx_memory_config_t contains the memory and timing fields for a corresponding memory device.

Split the configuration sequence into steps to fit with the use case

The configurations are set using:

  • HAL_NOR_SetConfig() to set the common configuration.

  • HAL_NOR_SetConfigxxxMemory() to set the device configuration.

  • HAL_NOR_SetWrAsyncTimings() to set different write timings configuration if needed.

Change timing parameters unit from cycle to ns

Static API is added to convert these values before setting them in the FMC register.

Split the process APIs and structures per CFI to and to interface with three CFIs (Common Flash Interface)

The control of the NOR memory input and output access and structures is split into these three command sets:

  • Command Set ID 0001 (HAL_NOR_CFI_0001).

  • Command Set ID 0002 (HAL_NOR_CFI_0002).

  • Command Set ID 0003 (HAL_NOR_CFI_0003).